package dd.view;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JButton;

import dd.model.Event;
import dd.model.Model;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.nio.channels.ClosedByInterruptException;
import java.util.ArrayList;

import dd.control.CloseEventSubmitChoiceButtonController;

import javax.swing.JTextField;

public class SetChoicesForClosedEvent extends JFrame {

	private JPanel contentPane;
	String EventName;
	Event event;
	
	ArrayList<JTextField> ChoicesTextfield = new ArrayList();
	ArrayList<JLabel> ChoicesLabel = new ArrayList();
	ArrayList<String> Choices = new ArrayList();

	public SetChoicesForClosedEvent() {
		setTitle("Set Choices");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		Model model = Model.getInstance();
		this.event = model.getEvent();
		EventName = event.getName();
		JLabel lblNewLabel = new JLabel("Moderator Set Choices For Closed Event "+EventName);
		lblNewLabel.setBounds(23, 6, 370, 29);
		contentPane.add(lblNewLabel);
		
		
		
		
		JButton btnNewButton = new JButton("Confirm Choices");
		btnNewButton.addActionListener(new CloseEventSubmitChoiceButtonController(this));
		btnNewButton.setBounds(160, 243, 130, 29);
		contentPane.add(btnNewButton);
		
		int i;
		int j;
		j = event.getNumberLines();
		JLabel label;
		JTextField textField;
		for(i=0;i<j;i++){
		
		label = new JLabel("choice"+i);
		label.setBounds(44, 71+i*30, 61, 16);
		contentPane.add(label);
		ChoicesLabel.add(label);
		
		textField = new JTextField();
		textField.setBounds(126, 65+i*30, 134, 28);
		contentPane.add(textField);
		ChoicesTextfield.add(textField);
		}

	}

	public ArrayList<JTextField> getChoices(){
		return ChoicesTextfield;
	}
}
